package com.shuqi.activity.viewport;

import android.text.InputFilter.LengthFilter;
import android.text.Spanned;

import com.shuqi.common.utils.ToastUtil;

public class EditTextLengthFilter extends LengthFilter {

    private int mLen;

    public EditTextLengthFilter(int len) {
        super(len);
        mLen = len;
    }

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
            int dend) {
        int keep = mLen - (dest.length() - (dend - dstart));
        if (keep <= 0) {
            ToastUtil.showMessage("密码过长，请输入6-16位密码");
        }
        return super.filter(source, start, end, dest, dstart, dend);
    }

}
